Ext.define('AmpleHarvest.objects.aqb.search.cSearch',
{
	extend			: 'Ext.panel.Panel',
	alias			: 'widget.ampleharvest-objects-aqb-search-csearch',
	requires		:
	[
//			"AmpleHarvest.objects.aqb.search.cAreaNorth",
			"AmpleHarvest.objects.search.results.panel.cOutput",
			"AmpleHarvest.eventHandler.cWindowEvents",
			"AmpleHarvest.objects.search.template.cReaperDisplay"
	],
	flext			: 1,
	layout			: 'border',

	initComponent	: function()
	{
		var obj_This = this;

//		var util_db_dmetedata = Ext.create('AmpleHarvest.util.solrFacets');
//		util_db_dmetedata.getData('entity', '');
		
		
		this.m_str_OutputTPL = new Ext.XTemplate(
				'<p>{content}</p>',
				'Link : <span class = "link" ',
				'onclick="m_obj_AmpleHarvest_ViewPort.fireEvent(AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_ARTICLE_OPEN,\'{id}\');">',
				'{title}</span>'
		);

		this.m_obj_SearchWin = Ext.create("AmpleHarvest.objects.aqb.search.cAreaNorth",
				{
					json	: this.json
				}
			);
		this.m_obj_OutputWin = Ext.create("AmpleHarvest.objects.search.results.panel.cOutput",
				{
					region			: "center",
					m_int_OutputTPL	: new AmpleHarvest.objects.search.template.cReaperDisplay()
				});

		this.items =
		[
				this.m_obj_SearchWin, 
				this.m_obj_OutputWin
		]
		this.callParent();

//		this.m_obj_SystemEvents = Ext.create(
//				"AmpleHarvest.eventHandler.cWindowEvents",
//				{
//					m_obj_MsgBus	: obj_This,
//					m_obj_Desktop	: obj_This
//				}
//		);
	},

	do_Search		: function()
	{
		this.loadURL();
	},

	loadURL			: function()
	{
		this.m_obj_OutputWin.loadURL(this.get_Query(), true);
	},

	get_JsonQuery	: function()
	{
		var obj_Temp = this.m_obj_SearchWin.get_QueryObject();
		obj_Temp.Sort = this.m_obj_OutputWin.get_SortArray();

		return Ext.encode(obj_Temp);
	},

	get_Query		: function()
	{
		var obj_Temp = new Object();
		obj_Temp.Json_Query = this.get_JsonQuery();;

		return obj_Temp;
	}
}
);
